<template>
    <section class="content" v-show="show">
        <h1>1、请点击右上方“三个点”</h1>
        <img src="~path_img/alt-1.jpg" alt="">
        <h1>2、选择在浏览器里打开下载pdf</h1>
        <img src="~path_img/alt-2.jpg" alt="">
    </section>
</template>

<script>
    export default {
        name: "anzhuo",
        data(){
            return {
                show: this.$common.isWeiXin(),
                token: this.$route.query.token,
                id: this.$route.query.id,
                pdf: this.$route.query.pdf
            }
        },
        mounted() {
            if(!this.show){
                this.$https.fetchGet_pdf2('/download_pdf?id=' + this.id +'&cc='+Math.random(0,100)+'&type=m',{},this.token).then( res => {
                    if(res.data.type == 'application/json'){
                        this.$toast('非法下载')
                    }
                    else{
                        // const blob = res.data;
                        const blob = new Blob([res.data], { type: 'application/pdf'});
                        const link = document.createElement('a');

                        link.href = window.URL.createObjectURL(blob);
                        link.download = this.pdf;
                        document.body.appendChild(link);
                        link.click();
                        window.URL.revokeObjectURL(link.href)
                    }

                })
            }
        }
    }
</script>

<style scoped lang="less">
.content{
    padding:0 .4rem;
    h1{
        font-size: .5rem;
        padding: .5rem 0;
        text-align: left;
    }
    img{
        width: 100%;
    }
}
</style>
